i = 0
nn.results <- list()
for (year in start.year:end.year) {
  i = i + 1
  print(year)
  # Fit NN
  nn.results[[i]] <- list()
  dta.past <- dta[dta[,t.var]< year,]
  N <- length(dta.past[,dv])
  hours <- floor((proc.time()[3]-start.time)/3600)
  mins <- floor((proc.time()[3]-start.time)/60) - hours*60
  secs <- floor((proc.time()[3]-start.time)) - hours*3600 - mins*60
  
  print(paste(hours,
              "h",
              mins,
              "m",
              secs,
              "s elapsed",
              sep = ""))
 
  dta.past.rhs <- dta.past[,rhs]
  set.seed(i)
  mod <- nnet(x = dta.past.rhs,
              y = as.matrix(dta[dta[,t.var]< year,
                                dv]),
              size = 7,
              decay = .15,
              trace = FALSE,
              MaxNWts = 8000
  )
  nn.results[[i]]$fit.oos <- predict(mod,
                                     newdata = dta[dta[,t.var]== year,rhs])
  nn.results[[i]]$actual.oos <- as.matrix(dta[dta[,t.var] == year,
                                              dv])
  print(year)
}
save(nn.results,file=paste(modeldir,"/",
                              country,
                              "_nn2_",
                              v,
                              "_",
                              rhs.group,
                              ".RData",
                              sep = ""))